<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:a4j="http://richfaces.org/a4j" template="layouts/layout.xhtml"
   >
   <ui:define name="content">
<h:form>
<rich:panel id="unitAddPanel">
        <f:facet name="header">
            <h:outputText value="Define Units"></h:outputText>
        </f:facet>

            
            <a4j:outputPanel id="MyPanelShow" >
            
              <h:panelGrid columns="2">
        
         <h:outputText value="Unit Define Type: "/>
        <rich:inplaceSelect defaultLabel="start typing for select" openOnEdit="false" value="#{wsUnitController.selectedType}">
        <a4j:ajax event="change" listener="#{wsUnitController.showCompound}"  render="MyPanelShow" /> 
               <f:selectItems value="#{wsUnitController.model.wsUnitDTO}" var="units" 
    		itemLabel="#{units.unitDefineTitle}" itemValue="#{units.unitDefineType}" />
            </rich:inplaceSelect>
            </h:panelGrid>
            
            <rich:panel id="Simple" rendered="#{wsUnitController.simple}">
              <h:panelGrid columns="3">
           <h:outputText value="Unit : "/>
            <rich:inplaceInput id="sss" name="sss" required="true" value="#{wsUnitController.model.unitName}"  defaultLabel="Enter your Units " minInputWidth="150px;" />
            
             <rich:message  for="sss">
                        <f:facet name="errorMarker">
                           
                        </f:facet>
                    </rich:message>
                    
            <h:outputText value="Desc:" />
            <rich:inplaceInput name="hello" id="hello" value="#{wsUnitController.model.unitDesc}" defaultLabel="Word you remeber" minInputWidth="150px;"/>
            <rich:message  for="hello">
             <f:facet name="errorMarker">
              </f:facet>
                    </rich:message>
                    
            </h:panelGrid>
             <a4j:commandButton id="twoandone" type="submit" actionListener="#{wsUnitController.addUnit}" value="Save Unit" render="MyPanelShow"  />
             </rich:panel>
             
             
             
             <rich:panel id="Compound" rendered="#{wsUnitController.compound}" >
             <h:panelGrid columns="2">
             <h:outputText value=" Example: "/>
              <h:outputText value="kg of 1000 gms "/>
              </h:panelGrid>
              <h:panelGrid columns="7">
             
             <rich:inplaceSelect id="primaryUnit" required="true"  defaultLabel="--select--"  value="#{wsUnitController.model.parentID}"  openOnEdit="true">
               <f:selectItems value="#{wsUnitController.models}" var="units" 
    		itemLabel="#{units.unitName}" itemValue="#{units.unitID}" />
            </rich:inplaceSelect>
             <rich:message  for="primaryUnit">
                        <f:facet name="errorMarker">
                           
                        </f:facet>
                    </rich:message>
            
              of
            
              <rich:inplaceInput id="relater" required="true" value="#{wsUnitController.model.twoUnitsRelator}"  defaultLabel="---Of---" minInputWidth="75px;" />
             
              <rich:message  for="relater">
                        <f:facet name="errorMarker">
                           
                        </f:facet>
                    </rich:message>
              
               <rich:inplaceInput id="secondaryUnit" required="true" value="#{wsUnitController.model.unitName}"  defaultLabel="...........New Unit............." minInputWidth="300px;" />
        
             
      
             <rich:message  for="secondaryUnit">
                        <f:facet name="errorMarker">
                           
                        </f:facet>
                    </rich:message>
            </h:panelGrid>
            
            
             <h:panelGrid columns="2">
               <h:outputText value="Desc:" />
          
            <h:inputTextarea id="textarea"  value="#{wsUnitController.model.unitDesc}" rows="5" cols="40" >
             </h:inputTextarea>
             
            </h:panelGrid>
             <a4j:commandButton id="two" type="submit" actionListener="#{wsUnitController.addUnit}" value="Save Unit" render="MyPanelShow"  >
              <f:param value="true" name="isCompound"/> 
              </a4j:commandButton>
             </rich:panel>
             
             
             </a4j:outputPanel>
    
            
       
            
            
     
      </rich:panel>
      
</h:form>
</ui:define>
</ui:composition>
